home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SNIP9_91.ARJ / UUDECODE.C < prev    next >
C/C++ Source or Header  |  1990-08-27  |  959b  |  36 lines

  1. /*
  2. ** by: John Lots
  3. */
  4.  
  5. #include        <stdio.h>
  6. #define         DEC(c)  (((c)-' ')&077)
  7.  
  8. main()
  9. {
  10.         int     n;
  11.         char    buf[128],a,b,c,d;
  12.  
  13.         scanf("begin %o ", &n);
  14.         gets(buf);                              /* filename */
  15.         if (!freopen(buf, "w", stdout))         /* oops.. */
  16.         {
  17.                 perror(buf);
  18.                 exit(1);
  19.         }
  20.         while ((n=getchar())!=EOF&&n=DEC(n))
  21.         {
  22.                 while (n>0)
  23.                 {
  24.                         a=DEC(getchar());
  25.                         b=DEC(getchar());
  26.                         c=DEC(getchar());
  27.                         d=DEC(getchar());
  28.                         if (n-->0) putchar(a<<2|b>>4);
  29.                         if (n-->0) putchar(b<<4|c>>2);
  30.                         if (n-->0) putchar(c<<6|d);
  31.                 }
  32.                 n=getchar();                    /* skip \n */
  33.         }
  34.         exit(0);
  35. }
  36.